#include "liblut/gui/wx/LutWxPanelView.h"

#include <wx/image.h>
#include <wx/bmpbuttn.h> // bitmapButoon include
#include <wx/xrc/xmlres.h>

extern void InitXmlResource();

LutWxPanelView::LutWxPanelView(wxWindow* parent,
                                wxWindowID id ,
                                const wxPoint& pos ,
                                const wxSize& size ,
                                long style)
               :wxPanel(parent, id, pos, size, style,wxT("LutWxPanel"))
{
    wxInitAllImageHandlers();
    wxXmlResource::Get()->InitAllHandlers();
    InitXmlResource();
    SetMinSize(wxSize(350,400));
    SetMaxSize(wxSize(400,600));
    //------------------------------------------
    wxBoxSizer *horSizer = new wxBoxSizer( wxVERTICAL );
    initBitmapButton(horSizer);
    horSizer->AddSpacer(4);
    LutWxBitmapView* imgpanel= new LutWxBitmapView(this,wxID_ANY,wxPoint(0,0),
                                                wxSize(330,200),style);
    horSizer->Add(imgpanel,0,wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_TOP,3);
    //initlutImage(horSizer);
    horSizer->AddSpacer(4);
    LutWxGridView* gridpanel= new LutWxGridView(this,wxID_ANY,wxPoint(0,0),
                                                wxSize(330,200),style);
    horSizer->Add(gridpanel,0,wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_TOP,3);
    //-------------------------------------------
    SetSizer(horSizer);
    horSizer->SetSizeHints(this);
    Layout();
}

void
LutWxPanelView::initBitmapButton(wxSizer* psizer){

    wxBoxSizer* bitmapSizer = new wxBoxSizer( wxHORIZONTAL );
    bitmapSizer->SetMinSize(60,20);
    //open
    bitmapSizer->AddStretchSpacer(3);
    wxBitmap bmpOpen=wxXmlResource::Get()->LoadBitmap(
                wxT("DOCUMENT-OPEN_16x16"));
    wxBitmapButton* bbopen= new wxBitmapButton(this, wxID_ANY, bmpOpen);
    bitmapSizer->Add(bbopen,0, wxALIGN_LEFT,2);
    //new
    bitmapSizer->AddSpacer(3);
    wxBitmap bmpNew=wxXmlResource::Get()->LoadBitmap(
                wxT("DOCUMENT-NEW_16x16"));
    wxBitmapButton* bbNew= new wxBitmapButton(this, wxID_ANY, bmpNew);
    bitmapSizer->Add(bbNew,0, wxALIGN_LEFT,2);
    //Save
    bitmapSizer->AddSpacer(3);
    wxBitmap bmpSave=wxXmlResource::Get()->LoadBitmap(
                wxT("DOCUMENT-SAVE_16x16"));
    wxBitmapButton* bbSave= new wxBitmapButton(this, wxID_ANY, bmpSave);
    bitmapSizer->Add(bbSave,0, wxALIGN_LEFT,2);
    //
    psizer->Add(bitmapSizer,0,wxEXPAND|wxALIGN_TOP,3);
}

//*****************************************************************************
//*****************************************************************************

LutWxBitmapView::LutWxBitmapView(wxWindow* parent,
                                wxWindowID id ,
                                const wxPoint& pos ,
                                const wxSize& size ,
                                long style)
               :wxPanel(parent, id, pos, size, style,wxT("LutWxBitmapView"))
{
    //SetMinSize(wxSize(264,104));
    //SetMaxSize(wxSize(400,600));
    wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer* imgSizer = new wxBoxSizer( wxHORIZONTAL );
    imgSizer->SetMinSize(260,62);
    m_image = new wxImage(256,60);
    m_image_ctrl = new wxStaticBitmap(this,
                                    wxID_ANY,
                                    wxBitmap(*m_image),
                                    wxDefaultPosition,
                                    wxSize(256,60));
    imgSizer->AddStretchSpacer(1);
    imgSizer->Add(m_image_ctrl,0,
                wxEXPAND|wxALIGN_CENTRE_VERTICAL,
                2);
    imgSizer->AddStretchSpacer(1);
    vertSizer->Add(imgSizer,0,wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_TOP,3);
    SetSizer(vertSizer);
    vertSizer->SetSizeHints(this);
    Layout();
}

//*****************************************************************************
//*****************************************************************************

LutWxGridView::LutWxGridView(wxWindow* parent,
                                wxWindowID id ,
                                const wxPoint& pos ,
                                const wxSize& size ,
                                long style)
               :wxPanel(parent, id, pos, size, style,wxT("LutWxPanel"))
{
    wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer* gridSizer = new wxBoxSizer( wxHORIZONTAL );

    m_grid=new wxGrid(this,wxID_ANY,wxPoint(0,0),wxSize(250,250));
    m_grid->CreateGrid(6,3);
    //m_grid->HideRowLabels();
    m_grid->SetColLabelValue(0,wxT("Value"));
    m_grid->SetColSize(0,75);
    m_grid->SetColLabelValue(1,wxT("Color"));
    m_grid->SetColSize(1,75);
    m_grid->SetColLabelValue(2,wxT("Desc"));
    m_grid->SetColSize(2,150);
    gridSizer->AddStretchSpacer(1);
    gridSizer->Add(m_grid,0,wxEXPAND|wxALIGN_CENTRE_VERTICAL,3);
    gridSizer->AddStretchSpacer(1);
    vertSizer->Add(gridSizer,0,wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_TOP,3);
    SetSizer(vertSizer);
    vertSizer->SetSizeHints(this);
    Layout();
}


